<template>
  <div class="table-search-page">
    <div class="g-tabs-wrapper">
      <a-tabs :activeKey="currentActiveKey" type="line" @change="changeTabs">
        <a-tab-pane :key="1" tab="未收费"></a-tab-pane>
        <a-tab-pane :key="2" tab="已收费"></a-tab-pane>
        <a-tab-pane :key="3" tab="已退回"></a-tab-pane>
        <a-tab-pane :key="4" tab="已作废"></a-tab-pane>
      </a-tabs>
    </div>
    <a-card :bordered="false" class="g-mt-10">
      <div class="table-page-search-wrapper">
        <a-form :form="form" :selfUpdate="true" layout="inline">
          <a-row :gutter="24">
            <a-col :lg="5" :md="12" :sm="12" style="padding: 0 4px;">
              <a-form-item label="开单日期">
                <a-range-picker v-decorator="['time']" allow-clear style="width: 100%;">
                  <a-icon slot="suffixIcon" type="calendar"/>
                </a-range-picker>
              </a-form-item>
            </a-col>
            <a-col :lg="5" :md="12" :sm="12" style="padding: 0 4px;">
              <a-form-item label="客户卡号">
                <a-input v-decorator="['cardNo']" allow-clear placeholder="客户卡号"/>
              </a-form-item>
            </a-col>
            <a-col :lg="5" :md="12" :sm="12" style="padding: 0 4px;">
              <a-form-item label="联系号码">
                <a-input v-decorator="['mobile']" allow-clear placeholder="联系号码"/>
              </a-form-item>
            </a-col>
            <a-col :lg="5" :md="12" :sm="12" style="padding: 0 4px;">
              <a-form-item label="客户姓名">
                <a-input v-decorator="['name']" allow-clear placeholder="姓名" style="width: 100%"/>
              </a-form-item>
            </a-col>
            <a-col :lg="4" :md="2" :sm="12">
              <div class="table-page-search-submitButtons g-flex" style="margin-bottom: 4px;">
                <a-icon :type="advanced ? 'up' : 'down'" style="margin-right: 15px;" @click="advanced=!advanced"/>
                <a-button type="primary" @click="clickSearch">查询</a-button>
                <a-button style="margin-left: 8px" @click="clickReset">重置</a-button>
              </div>
            </a-col>
          </a-row>
          <a-row v-show="advanced" :gutter="24">
            <a-col v-if="currentActiveKey!==1" :lg="5" :md="12" :sm="12" style="padding: 0 4px;">
              <a-form-item label="收费日期">
                <a-range-picker v-decorator="['chargeTime']" allow-clear style="width: 100%;">
                  <a-icon slot="suffixIcon" type="calendar"/>
                </a-range-picker>
              </a-form-item>
            </a-col>
            <a-col v-if="currentActiveKey==3" :lg="5" :md="12" :sm="12" style="padding: 0 4px;">
              <a-form-item label="退回日期">
                <a-range-picker v-decorator="['returnTime']" allow-clear style="width: 100%;">
                  <a-icon slot="suffixIcon" type="calendar"/>
                </a-range-picker>
              </a-form-item>
            </a-col>
            <a-col v-if="currentActiveKey==4" :lg="5" :md="12" :sm="12" style="padding: 0 4px;">
              <a-form-item label="作废日期">
                <a-range-picker v-decorator="['refundTime']" allow-clear style="width: 100%;">
                  <a-icon slot="suffixIcon" type="calendar"/>
                </a-range-picker>
              </a-form-item>
            </a-col>
            <a-col :lg="5" :md="12" :sm="12" style="padding: 0 4px;">
              <a-form-item label="开单人">
                <a-select
                  v-decorator="['biller']"
                  :showSearch="true"
                  allow-clear
                  option-filter-prop="children"
                  option-label-prop="label"
                  placeholder="选择，搜索"
                  style="width: 100%">
                  <a-select-option
                    v-for="item in allHisUser.userList"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id">{{ item.name }}
                  </a-select-option>
                </a-select>
              </a-form-item>
            </a-col>

            <a-col v-if="currentActiveKey!==1" :lg="5" :md="12" :sm="12" style="padding: 0 4px;">
              <a-form-item label="收银员">
                <a-select
                  v-decorator="['cashier']"
                  :showSearch="true"
                  allow-clear
                  option-filter-prop="children"
                  option-label-prop="label"
                  placeholder="选择，搜索"
                  style="width: 100%">
                  <a-select-option
                    v-for="item in allHisUser.userList"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id">{{ item.name }}
                  </a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <template v-if="currentActiveKey!==1">
              <a-col :lg="5" :md="12" :sm="12" style="padding: 0 4px;">
                <a-form-item label="项目科室">
                  <a-select
                    v-decorator="['execDept']"
                    :showSearch="true"
                    allow-clear
                    option-filter-prop="children"
                    option-label-prop="label"
                    placeholder="选择，搜索"
                    style="width: 100%">
                    <a-select-option v-for="item in deptList" :key="item.id" :label="item.name" :value="item.id">
                      {{ item.name }}
                    </a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
<!--              <a-col :lg="5" :md="12" :sm="12" style="padding: 0 4px;">-->
<!--                <a-form-item label="项目分类">-->
<!--                  <a-tree-select-->
<!--                    v-decorator="['itemType']"-->
<!--                    :dropdownStyle="{ maxHeight: '450px', overflow: 'auto' }"-->
<!--                    :replaceFields="replaceFields"-->
<!--                    :treeData="treeData"-->
<!--                    allowClear-->
<!--                    placeholder="选择，搜索"-->
<!--                    show-search-->
<!--                    style="width: 100%"-->
<!--                    tree-node-filter-prop="title"-->
<!--                  >-->
<!--                    <span slot="title" slot-scope="{ id }">{{ id }}</span>-->
<!--                  </a-tree-select>-->
<!--                </a-form-item>-->
<!--              </a-col>-->
              <a-col :lg="5" :md="12" :sm="12" style="padding: 0 4px;">
                <a-form-item label="支付方式">
                  <a-select
                    v-decorator="['payType']"
                    :showSearch="true"
                    allow-clear
                    option-filter-prop="children"
                    option-label-prop="label"
                    placeholder="选择，搜索"
                    style="width: 100%">
                    <a-select-option v-for="item in payType" :key="item.id" :label="item.name" :value="item.id">
                      {{ item.name }}
                    </a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
            </template>
          </a-row>
        </a-form>
      </div>
    </a-card>

    <a-card :bordered="false">
      <!--未收费-->
      <span v-if="currentActiveKey===1">
        <a-radio-group v-model="queryParam.chargeType" style="position: absolute;top: 8px;" @change="changeRadio">
          <a-radio-button :value="1">项目</a-radio-button>
          <a-radio-button :value="3">预存款</a-radio-button>
        </a-radio-group>
        <super-table
          ref="table"
          size="small"
          :columns="columns_no_charge"
          :data="loadData"
          :rowKey="(record,index)=> index"
          :scroll="{ x: 1300}"
        >
          <!--序号-->
          <template slot="index" slot-scope="text,record,index">
            <span>{{ (queryParam.pageNum - 1) * queryParam.pageSize + (index + 1) }}</span>
          </template>
          <!--客户卡号-->
          <template slot="cardNo" slot-scope="text,record">
            <div class="g-flex g-y-center">
              <a class="g-f-14" @click="toDetails(text, record)">{{ text }}</a>
              <a-tooltip placement="top">
                <template slot="title"> 复制 </template>
                <a-icon
                  style="margin-left: 10px;cursor: pointer;"
                  theme="twoTone"
                  two-tone-color="#3399ff"
                  type="copy"
                  @click="ConCopy(text)"/>
              </a-tooltip>
            </div>
          </template>
          <!--状态-->
          <template slot="chargeState" slot-scope="text">
            <a-tag v-if="text==0" color="orange">未收款</a-tag>
            <a-tag v-else-if="text==1" color="orange">未收完</a-tag>
            <a-tag v-else-if="text==2" color="green">已收完</a-tag>
            <a-tag v-else-if="text==3" color="green">已作废</a-tag>
            <a-tag v-else>{{ text }}</a-tag>
          </template>
          <!-- 应收金额 -->
          <template slot="totalPayableAmt" slot-scope="text,record">
            <a-statistic :precision="2" :value="record.totalPayableAmt" :value-style="{ color: '#3f8600'}">
              <template #prefix>¥</template>
            </a-statistic>
          </template>
          <!-- 成交金额 -->
          <template slot="totalChargeAmt" slot-scope="text,record">
            <a-statistic :precision="2" :value="record.totalChargeAmt" :value-style="{ color: '#3f8600' }">
              <template #prefix>¥</template>
            </a-statistic>
          </template>
          <template slot="action" slot-scope="text,record">
            <div class="g-flex">
              <a-button class="g-bt-pad-0" type="link" @click="openDrawer(record)">项目</a-button>
              <a-button
                v-show="queryParam.chargeType!=3"
                class="g-bt-pad-0"
                type="link"
                @click="clickItemCharge(record)">收费</a-button>
              <a-button
                v-show="queryParam.chargeType==3"
                class="g-bt-pad-0"
                type="link"
                @click="clickDepositCharge(record)">收费</a-button>
              <a-button class="g-bt-pad-0" type="link" @click="returnCharge(record)">退回</a-button>
            </div>
          </template>

        </super-table>
      </span>
      <!--已收费-->
      <span v-if="currentActiveKey==2">
        <a-radio-group v-model="queryParam.chargeType" style="position: absolute;top: 8px;" @change="changeRadio">
          <a-radio-button :value="1">项目</a-radio-button>
          <a-radio-button :value="3">预存款</a-radio-button>
        </a-radio-group>
        <template v-if="queryParam.chargeType!=3">
          <super-table
            ref="table"
            size="small"
            :columns="columns_had_charge_item"
            :data="loadData"
            :rowKey="(record,index)=> index"
            :scroll="{ x: 1300}"
          >
            <!--序号-->
            <template slot="index" slot-scope="text,record,index">
              <span>{{ (queryParam.pageNum - 1) * queryParam.pageSize + (index + 1) }}</span>
            </template>
            <!--客户卡号-->
            <template slot="cardNo" slot-scope="text,record">
              <div class="g-flex g-y-center">
                <a class="g-f-14" @click="toDetails(text, record)">{{ text }}</a>
                <a-tooltip placement="top">
                  <template slot="title"> 复制 </template>
                  <a-icon
                    style="margin-left: 10px;cursor: pointer;"
                    theme="twoTone"
                    two-tone-color="#3399ff"
                    type="copy"
                    @click="ConCopy(text)"/>
                </a-tooltip>
              </div>
            </template>
            <!--状态-->
            <template slot="chargeState" slot-scope="record">
              <a-tag v-if="record==0" color="orange">未收款</a-tag>
              <a-tag v-else-if="record==1" color="orange">未收完</a-tag>
              <a-tag v-else-if="record==2" color="green">已收完</a-tag>
              <a-tag v-else-if="record==3" color="green">已作废</a-tag>
              <a-tag v-else>{{ record }}</a-tag>
            </template>
            <!-- 应收金额 -->
            <template slot="totalPayableAmt" slot-scope="text,record">
              <a-statistic :precision="2" :value="record.totalPayableAmt" :value-style="{ color: '#3f8600'}">
                <template #prefix>¥</template>
              </a-statistic>
            </template>
            <!-- 成交金额 -->
            <template slot="totalChargeAmt" slot-scope="text,record">
              <a-statistic :precision="2" :value="record.totalChargeAmt" :value-style="{ color: '#3f8600' }">
                <template #prefix>¥</template>
              </a-statistic>
            </template>
            <!-- 成交金额 -->
            <template slot="totalPaidAmt" slot-scope="text">
              <a-statistic :precision="2" :value="text" :value-style="{ color: '#3f8600' }">
                <template #prefix>¥</template>
              </a-statistic>
            </template>
            <!-- 成交金额 -->
            <template slot="totalUnpaidAmt" slot-scope="text,record">
              <a-statistic :precision="2" :value="record.totalUnpaidAmt" :value-style="{ color: '#8b0717' }">
                <template #prefix>¥</template>
              </a-statistic>
            </template>
            <template slot="action" slot-scope="text,record">
              <div class="g-flex">
                <a-button class="g-bt-pad-0" type="link" @click="clickChargeDetails(record)">详情</a-button>
                <a-button class="g-bt-pad-0" type="link" @click="refund(record)">作废</a-button>
              </div>
            </template>
          </super-table>
        </template>
        <template v-else>
          <super-table
            ref="table"
            size="small"
            :columns="columns_had_charge_deposit"
            :data="loadData"
            :rowKey="(record,index)=> index"
            :scroll="{ x: 1300}"
          >
            <!--序号-->
            <template slot="index" slot-scope="text,record,index">
              <span>{{ (queryParam.pageNum - 1) * queryParam.pageSize + (index + 1) }}</span>
            </template>
            <!--客户卡号-->
            <template slot="cardNo" slot-scope="text,record">
              <div class="g-flex g-y-center">
                <a class="g-f-14" @click="toDetails(text, record)">{{ text }}</a>
                <a-tooltip placement="top">
                  <template slot="title"> 复制 </template>
                  <a-icon
                    style="margin-left: 10px;cursor: pointer;"
                    theme="twoTone"
                    two-tone-color="#3399ff"
                    type="copy"
                    @click="ConCopy(text)"/>
                </a-tooltip>
              </div>
            </template>
            <!--状态-->
            <template slot="chargeState" slot-scope="text">
              <a-tag v-if="text==0" color="orange">未收款</a-tag>
              <a-tag v-else-if="text==1" color="orange">未收完</a-tag>
              <a-tag v-else-if="text==2" color="green">已收完</a-tag>
              <a-tag v-else-if="text==3" color="green">已作废</a-tag>
              <a-tag v-else>{{ text }}</a-tag>
            </template>
            <template slot="action" slot-scope="text,record">
              <div class="g-flex">
                <a-button class="g-bt-pad-0" type="link" @click="refund(record)">作废</a-button>
              </div>
            </template>
          </super-table>
        </template>
      </span>
      <!--已退回-->
      <span v-if="currentActiveKey==3">
        <a-radio-group v-model="queryParam.chargeType" style="position: absolute;top: 8px;" @change="changeRadio">
          <a-radio-button :value="1">项目</a-radio-button>
          <a-radio-button :value="3">预存款</a-radio-button>
        </a-radio-group>
        <super-table
          ref="table"
          size="small"
          :columns="columns_refund"
          :data="loadData"
          :rowKey="(record,index)=> index"
          :scroll="{ x: 1300}"
        >
          <!--序号-->
          <template slot="index" slot-scope="text,record,index">
            <span>{{ (queryParam.pageNum - 1) * queryParam.pageSize + (index + 1) }}</span>
          </template>
          <!--状态-->
          <template slot="chargeState" slot-scope="text">
            <a-tag v-if="text==0" color="orange">未收款</a-tag>
            <a-tag v-else-if="text==1" color="orange">未收完</a-tag>
            <a-tag v-else-if="text==2" color="green">已收完</a-tag>
            <a-tag v-else-if="text==3" color="green">已作废</a-tag>
            <a-tag v-else>{{ text }}</a-tag>
          </template>
          <template slot="action" slot-scope="text,record">
            <a-button class="g-bt-pad-0" type="link" @click="openDrawer(record)">项目</a-button>
          </template>
          <!-- 应收金额 -->
          <template slot="totalPayableAmt" slot-scope="text,record">
            <a-statistic :precision="2" :value="record.totalPayableAmt" :value-style="{ color: '#3f8600'}">
              <template #prefix>¥</template>
            </a-statistic>
          </template>
          <!-- 成交金额 -->
          <template slot="totalPaidAmt" slot-scope="text,record">
            <a-statistic :precision="2" :value="record.totalChargeAmt" :value-style="{ color: '#3f8600' }">
              <template #prefix>¥</template>
            </a-statistic>
          </template>
        </super-table>
      </span>
      <!--已作废-->
      <span v-if="currentActiveKey==4">
        <a-radio-group v-model="queryParam.chargeType" style="position: absolute;top: 8px;" @change="changeRadio">
          <a-radio-button :value="1">项目</a-radio-button>
          <a-radio-button :value="3">预存款</a-radio-button>
        </a-radio-group>
        <template v-if="queryParam.chargeType!=3">
          <super-table
            ref="table"
            size="small"
            :columns="columns_had_refund_item"
            :data="loadData"
            :rowKey="(record,index)=> index"
            :scroll="{ x: 1300}"
          >
            <!--序号-->
            <template slot="index" slot-scope="text,record,index">
              <span>{{ (queryParam.pageNum - 1) * queryParam.pageSize + (index + 1) }}</span>
            </template>
            <!--状态-->
            <template slot="chargeState" slot-scope="text">
              <a-tag v-if="text==0" color="orange">未收款</a-tag>
              <a-tag v-else-if="text==1" color="orange">未收完</a-tag>
              <a-tag v-else-if="text==2" color="green">已收完</a-tag>
              <a-tag v-else-if="text==3" color="green">已作废</a-tag>
              <a-tag v-else>{{ text }}</a-tag>
            </template>
            <!-- 应收金额 -->
            <template slot="totalPayableAmt" slot-scope="text,record">
              <a-statistic :precision="2" :value="record.totalPayableAmt" :value-style="{ color: '#3f8600'}">
                <template #prefix>¥</template>
              </a-statistic>
            </template>
            <!-- 成交金额 -->
            <template slot="totalChargeAmt" slot-scope="text,record">
              <a-statistic :precision="2" :value="record.totalChargeAmt" :value-style="{ color: '#3f8600' }">
                <template #prefix>¥</template>
              </a-statistic>
            </template>
            <!-- 成交金额 -->
            <template slot="totalPaidAmt" slot-scope="text">
              <a-statistic :precision="2" :value="text" :value-style="{ color: '#3f8600' }">
                <template #prefix>¥</template>
              </a-statistic>
            </template>
            <!-- 成交金额 -->
            <template slot="totalUnpaidAmt" slot-scope="text,record">
              <a-statistic :precision="2" :value="record.totalUnpaidAmt" :value-style="{ color: '#8b0717' }">
                <template #prefix>¥</template>
              </a-statistic>
            </template>
            <template slot="action" slot-scope="text,record">
              <a-button class="g-bt-pad-0" type="link" @click="clickChargeDetails(record)">项目详情</a-button>
            </template>
          </super-table>
        </template>
        <template v-else>
          <super-table
            ref="table"
            size="small"
            :columns="columns_had_refund_deposit"
            :data="loadData"
            :rowKey="(record,index)=> index"
            :scroll="{ x: 1300}"
          >
            <!--序号-->
            <template slot="index" slot-scope="text,record,index">
              <span>{{ (queryParam.pageNum - 1) * queryParam.pageSize + (index + 1) }}</span>
            </template>
            <template slot="action" slot-scope="text,record">
              <a-button class="g-bt-pad-0" type="link" @click="clickChargeDetails(record)">项目详情</a-button>
            </template>
          </super-table>
        </template>
      </span>
    </a-card>
    <!--项目收费--弹窗-->
    <item-charge ref="itemCharge" :row_record="current_row_record" @itemChargeSuccess="itemChargeSuccess"></item-charge>
    <!--预存款收费--弹窗-->
    <deposit-charge
      ref="depositCharge"
      :row_record="current_row_record"
      @refresh="$refs.table.loadData()"></deposit-charge>
    <!--项目抽屉--弹窗-->
    <item-drawer ref="itemDrawer" :row_record="current_row_record"/>
    <!--收费详情--弹窗-->
    <charge-details-drawer ref="ChargeDetailsDrawer" :row_record="current_row_record"/>

  </div>
</template>

<script>
import {AllHisUser, CustomerLevel, CustomerState} from '@/api/customer/customer'
import {CustomerFeedback} from '@/api/modular/main/customer/customerReturnVisit'
import {financeList, returnOrder, refundOrder} from '@/api/modular/main/customer/cashier'
import {SuperTable, upTime} from '@/components'
import itemCharge from '@/views/customer/cashier/itemCharge'
import depositCharge from '@/views/customer/cashier/depositCharge'
import itemDrawer from '@/views/customer/cashier/itemDrawer'
import moment from 'moment'
import ChargeDetailsDrawer from '@/views/customer/cashier/ChargeDetailsDrawer'
import columns from '@/views/customer/cashier/js/column'
import payType from '@/assets/flowable/js/payType'
import {getDeptList, getItemClasssify} from '@/api/modular/main/customer/customerScene'

export default {
  components: {
    SuperTable,
    upTime,
    itemCharge,
    depositCharge,
    ChargeDetailsDrawer,
    itemDrawer
  },
  data() {
    return {
      loadData: parameter => {
        this.queryParam.pageNum = parameter.pageNum || 1
        this.queryParam.pageSize = parameter.pageSize || 10
        return financeList(this.queryParam).then(res => {
          this.loading = false//关闭加载
          return res
        })
      },
      form: this.$form.createForm(this),
      customerState: [],//客户状态
      customerLevel: [],//客户等级
      advanced: false, // 高级搜索 展开/关闭
      disabled: true, //是否禁用新增按钮
      current_row_record: {},
      columns_no_charge: columns.columns_no_charge,
      columns_had_charge_item: columns.columns_had_charge_item,
      columns_had_charge_deposit: columns.columns_had_charge_deposit,
      columns_refund: columns.columns_refund,
      columns_had_refund_item: columns.columns_had_refund_item,
      columns_had_refund_deposit: columns.columns_had_refund_deposit,
      // 查询参数
      queryParam: {
        pageNum: 1,//第几页
        pageSize: 10,//每页中显示数据的条数
        type: 1,
        beginTime: undefined,
        endTime: undefined,
        chargeType: 1
      },
      loading: true, //加载状态,
      current_row_index: '',
      customerFeedback: {},
      allHisUser: {}, //回访人对象
      currentActiveKey: 1,
      treeData: [],
      replaceFields: {
        title: 'name'
      },
      deptList: [],
      payType: payType
    }
  },
  created() {
    this.getBaseFormInfo()
  },
  // activated() {
  //   if(this.$store.state.app.multiTab){
  //     console.log('这里是激活缓存',this.$store.state.app)
  //     this.$refs.table.refresh(true)
  //   }
  // },
  methods: {
    moment,
    minutesToSeconds(time) {
      return parseInt(time)
    },
    changeRadio(e) {
      const value = e.target.value
      this.queryParam.chargeType = value
      this.$refs.table.loadData()
    },
    //点击查询-高级搜索
    clickSearch() {
      const form_values = this.form.getFieldsValue()
      const time = form_values.time
      const chargeTime = form_values.chargeTime
      const returnTime = form_values.returnTime
      const refundTime = form_values.refundTime

      //开单日期
      form_values.beginTime = (time && time.length) ? moment(time[0]).format('YYYY-MM-DD') : undefined
      form_values.endTime = (time && time.length) ? moment(time[1]).format('YYYY-MM-DD') : undefined
      form_values.time = undefined

      //收费日期
      form_values.chargeBeginTime = (chargeTime && chargeTime.length) ? moment(chargeTime[0]).format('YYYY-MM-DD') : undefined
      form_values.chargeEndTime = (chargeTime && chargeTime.length) ? moment(chargeTime[1]).format('YYYY-MM-DD') : undefined
      form_values.chargeTime = undefined

      //退回日期
      form_values.returnBeginTime = (returnTime && returnTime.length) ? moment(returnTime[0]).format('YYYY-MM-DD') : undefined
      form_values.returnEndTime = (returnTime && returnTime.length) ? moment(returnTime[1]).format('YYYY-MM-DD') : undefined
      form_values.returnTime = undefined

      //作废日期
      form_values.refundBeginTime = (refundTime && refundTime.length) ? moment(refundTime[0]).format('YYYY-MM-DD') : undefined
      form_values.refundEndTime = (refundTime && refundTime.length) ? moment(refundTime[1]).format('YYYY-MM-DD') : undefined
      form_values.refundTime = undefined


      this.queryParam = Object.assign(this.queryParam, form_values)
      this.$refs.table.refresh(true)
    },
    clickReset() {
      this.form.resetFields()
    },
    openDrawer(record) {
      this.current_row_record = record
      this.$refs.itemDrawer.show()
    },
    /**
     * 已收费-退费
     * **/
    refund(record) {
      var _this = this
      this.$confirm({
        title: '确认要将笔订单做作废处理吗？',
        content: h => <div style="color:red;">该订单将作废，如果再次收款，请前往未收费列表</div>,
        onOk() {
          const params = {orderId: record.orderId}
          refundOrder(params).then(res => {
            // console.log('退费结果',res)
            if (res.code == 200) {
              _this.$refs.table.refresh(true)
              _this.$message.success(res.message)
            } else {
              _this.$message.error(res.message)
            }
          })
        }
      })
    },
    returnCharge(record) {
      var _this = this
      this.$confirm({
        title: '确定要退回该笔订单吗？',
        content: h => <div style="color:red;">该订单将退回现场咨询，如果需要重新收费，请现场咨询再次提交</div>,
        onOk() {
          const orderId = record.orderId
          returnOrder({orderId}).then(res => {
            if (res.code == 200) {
              _this.$message.success('退回成功')
              _this.$refs.table.refresh()
            } else {
              _this.$message.info(res.message)
            }
          })
        },
        onCancel() {
          console.log('Cancel')
        },
        class: 'test'
      })

    },
    /***
     * 项目收费成功
     * **/
    itemChargeSuccess() {
      this.$refs.table.refresh()
    },
    /***
     * 已收费-详情
     * **/
    clickChargeDetails(record) {
      this.current_row_record = record
      this.$refs.ChargeDetailsDrawer.show()
    },
    /***
     * 未收齐-收费
     * **/
    clickArrearsCharge(record) {
      this.$router.push({
        path: '/arrearsToCharge'
      })
    },
    changeTabs(key) {
      this.currentActiveKey = key
      this.queryParam.type = key
      this.queryParam.chargeType = 1
      this.$nextTick(() => {
        this.$refs.table.refresh()
      })
    },
    //点击查看客户详情
    toDetails(text, record) {
      this.$router.push({
        path: 'customer_details', query: {
          id: record.customerId,
          card_no: record.cardNo,
          customerName:record.customerName
        }
      })
    },
    clickItemCharge(record) {
      this.current_row_record = record
      this.$refs.itemCharge.show()
    },
    clickDepositCharge(record) {
      this.current_row_record = record
      this.$refs.depositCharge.show()
    },
    //获取表单相关接口
    getBaseFormInfo() {
      getItemClasssify().then(res => {
        this.treeData = res.data
      })
      getDeptList().then((res) => {
        // console.log('科室列表', res.data)
        this.deptList = res.data
      })
      CustomerFeedback().then(res => {
        this.customerFeedback = res
      })
      AllHisUser().then(res => {
        // console.log('员工', res)
        this.allHisUser = res
      })
      CustomerLevel().then(res => {
        this.customerLevel = res
      })
      CustomerState().then(res => {
        this.customerState = res
      })
    }
  }

}
</script>

<style lang="less" scoped>
/deep/ .ant-statistic-content {
  font-size: 18px !important;
}

.table-operator {
  margin-bottom: 18px;
}

button {
  margin-right: 8px;
  margin-bottom: 2px;
}

.currentRowClass {
  background: #e6f7ff;
}

/deep/ .ant-tabs-bar {
  border-bottom: none;
}

/deep/ .ant-badge-count, .ant-badge-dot, .ant-badge .ant-scroll-number-custom-component {
  right: -10px;
}
</style>